// gl_buffers.h
//

class idRenderProg;
class idVertexBuffer;

struct idRenderMatrix
{
	XMMATRIX mView;
	XMMATRIX mProjection;
    XMMATRIX mWorld;
};

struct idDrawVert {
	idDrawVert();
	float		xyz[3];
	float		st[2];
	float		lightmapST[2];
	float		color[4];

	static ID3D11InputLayout * CreateDeviceVert( ID3DBlob* pVSBlob );

	void		SetPosition( float x, float y, float z) { xyz[0] = x; xyz[1] = y; xyz[2] = z; }
	void		SetST( float s, float t ) { st[0] = s; st[1] = t; }
	void		SetLightmapST(float s, float t) {lightmapST[0] = s; lightmapST[1] = t; }
	void		SetColor( float r, float g, float b ) { color[0] = r; color[1] = g; color[2] = b; color[3] = 1; }
	void		SetColorAlpha( float r, float g, float b, float a ) { color[0] = r; color[1] = g; color[2] = b; color[3] = a; }
};

ID_INLINE idDrawVert::idDrawVert() {
	xyz[0] = xyz[1] = xyz[2] = 0;
	//st[0] = st[1] = 0;
	color[0] = color[1] = color[2] = color[3] = 1;
}


//
// idVertexBuffer
//
class idVertexBuffer {
public:
							~idVertexBuffer();
	void					Init( int numVerts );
	void					Upload( idDrawVert *verts, int numVerts );
	void					Bind( void );

	int						GetNumVerts( void ) { return _numVerts; }
private:
	int						_numVerts;
	ID3D11Buffer*           g_pVertexBuffer;
};

//
// idIndexBuffer
//
class idIndexBuffer {
public:
							~idIndexBuffer();
	void					Init( int numIndexes );

	void					Upload( int *indexes, int numIndexes );

	void					Bind( void );

private:
	ID3D11Buffer*           g_pIndexBuffer;
};

//
// idConstantBuffer
//
class idConstantBuffer {
public:
	void					Init( int size, int num );

	void					Upload( void *buffer, int num );

	void					VSBind( int constantBufferSlot );
private:
	ID3D11Buffer*			g_pBuffer;
	int						_size;
};
